package cn.st4rlight.util.convert;

import org.apache.commons.lang3.StringUtils;

import cn.st4rlight.util.convert.base.IConverter;
import cn.st4rlight.util.exception.ConvertException;

/**
 * Double类型转换器
 *
 * @author st4rlight
 */
public class DoubleConverter implements IConverter<Double> {

    @Override
    public Double convert(String value) throws ConvertException {
        try {
            return Double.parseDouble(StringUtils.trimToEmpty(value));
        } catch (NumberFormatException e) {
            throw new ConvertException("无法将字符串\"" + value + "\"转换为Double类型", e);
        }
    }
}